<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/vue.js"></script>
</head>

<body>
    <div id="app">
        <!-- 
        v-bind
            - 缩写：: ，项目中可用 ： 替代 v-bind:
            - 语法：
                <p v-bind:参数="取值"></p>
                <p :参数="取值"></p>
            - 参数：attrOrProp (optional)
            - 取值：any (对应属性有效取值) | Object (对应属性取值)
                + 取值范围 和插值表达式一致
        -->
        <p v-bind:id=" 'pDom' ">绑定id</p>
        <p id="pDom1">绑定id</p>
        <p v-bind:id="idStr">绑定id</p>
        <input type="button" value="修改变量" @click=" idStr='bbbb' ">
        <hr>
        <input type="text" v-bind:disabled=" flag "><br>
        <input type="button" value="输入框状态切换" @click=" flag=!flag ">
        <hr>
        <input type="button" 
            v-bind:value=" code?s:'发送验证码' " 
            v-bind:disabled=" code " 
            @click=" sendCode() "
        >
        <hr>
        <h1 v-bind:style=" `color:${c}` ">测试数据</h1>
        <input type="button" value="red|blue" @click=" c = c=='blue'?'red':'blue' ">
    </div>
</body>
<script>
    // 以数据为驱动
    new Vue({
        el: "#app",
        data: {
            idStr: "aa",
            flag: false,
            code: false,
            s:10,
            c:"red"
        },
        methods:{
            sendCode(){
                this.code = true;
                let timer = setInterval(()=>{
                    // console.log(this);
                    this.s--;
                    // console.log(1);
                    if(this.s<=0){
                        this.code = false;
                        this.s = 10;
                        clearInterval(timer);
                    }
                },1000)
            }
        }
    })
</script>

</html>